package com.iot.core.data.service;


import com.iot.core.data.entity.HtUserDept;
import com.iot.core.data.mapper.HtUserDeptMapper;
import com.iot.core.manager.auth.HtDeptBaseDto;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.iot.core.data.entity.table.HtDeptTableDef.HT_DEPT;
import static com.iot.core.data.entity.table.HtMenuTableDef.HT_MENU;
import static com.iot.core.data.entity.table.HtPageAuthTableDef.HT_PAGE_AUTH;
import static com.iot.core.data.entity.table.HtPageTableDef.HT_PAGE;
import static com.iot.core.data.entity.table.HtRoleMenuTableDef.HT_ROLE_MENU;
import static com.iot.core.data.entity.table.HtUserDeptTableDef.HT_USER_DEPT;

@Service
public class HtUserDeptServiceImpl extends  ServiceImpl<HtUserDeptMapper, HtUserDept> implements IHtUserDeptService {

    public List<HtDeptBaseDto> getDepts(Long uid){
        var qw= QueryWrapper.create()
                .select(HT_DEPT.ALL_COLUMNS )
                .from(HT_USER_DEPT).as("a")
                .join(HT_DEPT).as("b")
                .on(HT_USER_DEPT.HTUSER_ID.eq(uid)
                        .and( HT_USER_DEPT.STATE.eq("启用"))
                        .and( HT_USER_DEPT.HTDEPT_ID.eq(HT_DEPT.ID) )
                );
        var l=getMapper().selectListByQueryAs(qw,HtDeptBaseDto.class);
        return l;
    }

}
